/**	
 * <br>
 * Copyright 2011 IFlyTek.All rights reserved.<br>
 * <br>			 
 * Package: com.iflytek.scheduledAgent.run <br>
 * FileName: AgentApp.java <br>
 * <br>
 * @version
 * @author xkfeng@iflytek.com
 * @created 2014-3-11
 * @last Modified 
 * @history
 */
package org.hulk.job.run;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 服务启动类
 * 
 * @author xkfeng@iflytek.com
 * @created 2014-3-11 下午01:49:40
 * @lastModified
 * @history
 */
public class EngineApp {
	/**
	 * logger
	 */
	private static Log log = LogFactory.getLog(EngineApp.class);

	/**
	 * 
	 * 服务启动
	 * 
	 * @param args
	 * @author xkfeng@iflytek.com
	 * @created 2014-3-11 下午01:50:08
	 * @lastModified
	 * @history
	 */
	public static void main(String[] args) {
		boolean flag = ApplicationLoader.loadContext();
		if (!flag) {
			log.fatal("启动发生异常，请检查相关配置后，再尝试启动。。。");
			System.exit(-1);
		}

//		 ((WebServer)ApplicationLoader.getContext().getBean("webServer")).start();
		// JAXRSServerFactoryBean factory = (JAXRSServerFactoryBean)
		// ApplicationLoader.getContext().getBean("restServer");
		// factory.create();
		/**
		 * 系统中断处理
		 */
		Runtime.getRuntime().addShutdownHook(new Thread() {
			public void run() {
				System.err.println("准备停止系统...");
				ApplicationLoader.getContext().close();
			}
		});
	}
}
